package com.Jhu1.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.Jhu1.entity.Material;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @author Jhu1
 * @description 针对表【material】的数据库操作Mapper
 * @createDate 2025-01-16 20:19:37
 * @Entity com.yin.entity.Material
 */
@Mapper
public interface MaterialMapper extends BaseMapper<Material> {
    @Select("""
            select * from material
            where material_name like concat('%',#{name},'%')
            """)
    List<Material> getMaterialList(String name);
    
    @Insert("""
            insert into material(material_name, material_price, create_time, update_time)
            values(#{materialName},#{materialPrice},now(),now())
            """)
    void add(String materialName, double materialPrice);
    
    @Delete("""
            delete from material
            where id = #{id}
            """)
    void delete(Integer id);
    
    @Update("""
            update material
            set material_name = #{materialName},material_price = #{materialPrice},update_time = now()
            where id = #{id}
            """)
    void update(Integer id, String materialName, double materialPrice);
}




